package 笔试记录.M9day22深信服;

public class Main3 {
    public int histogram_max_area (int[] histogram) {
        // write code here
        int max = -1;
        int n = histogram.length;
        for (int i = 0; i < n; i++) {
            int left = i;
            int right = i;
            //开始向左右边界寻找大于等于当前下标的值
            while(left > 0 && histogram[left - 1] >= histogram[i]) left--;//右边界确定
            while(right <= n - 1 && histogram[right + 1] >= histogram[i]) right++;
            int res = (right - left + 1) * histogram[i];
            max = res > max ? res : max;
        }
        return max;
    }
}
